package com.woniu.project.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.project.core.domain.ManagementRole;
import com.woniu.project.core.domain.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Klaus
 * @since 2020-10-13
 */
public interface ManagementRoleMapper extends BaseMapper<ManagementRole> {

    /**
     * 根据管理员ID查询该管理员所拥有的所有角色ID
     * @param managementId
     * @return
     */
    @Select("select management_role_id,management_id\n" +
            ",role_id from pawn_management_role \n" +
            "where management_id = #{managementId}")
    List<ManagementRole> selectRoleByManagementId(Integer managementId);

    @Delete("DELETE from pawn_management_role where management_id =#{managementId} and role_id =#{RoleId}")
    void deleteManagementRoleByManagementIdAndRoleId(@Param("managementId") Integer managementId,@Param("RoleId") Integer RoleId);

    @Select("SELECT management_role_id,management_id\n" +
            ",role_id from pawn_management_role ")
    List<ManagementRole> selectAllList();
}
